home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <Xm/Xm.h>
- #include <X11/StringDefs.h>
- #include <Xm/Form.h>
- #include <Xm/RowColumn.h>
- #include <Xm/SeparatoG.h>
- #include <Xm/PushB.h>
- #include <Xm/Label.h>
- #include "exbookglo.h"
- #include "exinterfmotif.h"
- #ifdef DEBUG
- #include <malloc.h>
- #endif
- /*
- #include "exglobals.h"
- */
-
- extern char *(extract_first_xms_segment() );
- extern struct indexlist *(find_keyword_int() );
- extern struct indexlist *(find_keyword() );
- extern struct indexlist *(add_keyword() );
- extern struct icntmpltstruct **duplicate_icons;
- extern int find_blank(char *s);
- extern int dup_icn_cnt;
- int dup_number;
- static struct iconstruct *lasticonptr;
-
- Widget DupIcons_shell;
- Widget AskDupIcons_shell;
- Widget AskDupLabel;
- Widget ONameLabel, OCommandLabel, OKeywordLabel, OFilesLabel, OGroupsLabel;
- Widget OAltCommandLabel, OHelpFileLabel;
- Widget DNameLabel, DCommandLabel, DKeywordLabel, DFilesLabel, DGroupsLabel;
- Widget DAltCommandLabel, DHelpFileLabel;
-
- void popup_AskDupIcons(int dup_icn_cnt);
- void resolveCB_AskDupIcons(Widget w,XtPointer client_data, XtPointer call_data);
- void ignoreCB_AskDupIcons(Widget w, XtPointer client_data, XtPointer call_data);
- void noCB_DupIcons(Widget w, XtPointer client_data, XtPointer call_data);
- void yesCB_DupIcons(Widget w, XtPointer client_data, XtPointer call_data);
-
- Widget create_DupIcons()
- {
- Widget topform;
- Widget label, rc1, rc2, y_button, n_button;
- Widget rc3;
- Widget bottom_form, form, sep;
- Arg wargs[15];
- int n;
- XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
-
- DupIcons_shell = XtVaCreatePopupShell( "DupIconsshell",
- topLevelShellWidgetClass, DBtoplevel,
- XmNtitle, "Duplicate Icons",
- XmNallowShellResize, TRUE, NULL);
-
- n = 0;
- XtSetArg (wargs[n], XmNverticalSpacing, 10); n++;
- XtSetArg (wargs[n], XmNhorizontalSpacing, 10); n++;
- topform = XtCreateManagedWidget("AskDupIconsTopForm", xmFormWidgetClass,
- DupIcons_shell, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNbottomAttachment, XmATTACH_FORM); n++;
- bottom_form = XtCreateManagedWidget( "DupIBottomForm", xmFormWidgetClass,
- topform, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNverticalSpacing, 10); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_FORM); n++;
- sep = XtCreateManagedWidget("Sep", xmSeparatorGadgetClass,
- bottom_form, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, sep); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- label = XtCreateManagedWidget("QuestionLabel", xmLabelWidgetClass,
- bottom_form, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNbottomAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, sep); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNleftWidget, label); n++;
- y_button = XtCreateManagedWidget( "YesButton", xmPushButtonWidgetClass,
- bottom_form, wargs, n);
- XtAddCallback( y_button, XmNactivateCallback, yesCB_DupIcons, NULL);
-
- n = 0;
- XtSetArg (wargs[n], XmNbottomAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, sep); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNleftWidget, y_button); n++;
- n_button = XtCreateManagedWidget( "NoButton", xmPushButtonWidgetClass,
- bottom_form, wargs, n);
- XtAddCallback( n_button, XmNactivateCallback, noCB_DupIcons, NULL);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNbottomWidget, bottom_form); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_FORM); n++;
- form = XtCreateManagedWidget( "DupIForm1", xmFormWidgetClass,
- topform, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- label = XtCreateManagedWidget("OriginalLabel", xmLabelWidgetClass,
- form, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, label); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc1 = XtCreateManagedWidget("RC", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("NameLabel", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- ONameLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc1); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc2 = XtCreateManagedWidget("RC2", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("CommandLabel", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- OCommandLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc2); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc3 = XtCreateManagedWidget("RC3", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("AltCommandLabel", xmLabelWidgetClass,
- rc3, wargs, n);
-
- n = 0;
- OAltCommandLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc3, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc3); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc2 = XtCreateManagedWidget("RC2", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("HelpFileLabel", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- OHelpFileLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc2); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc1 = XtCreateManagedWidget("RC", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("KeywordsLabel", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- OKeywordLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc1); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc2 = XtCreateManagedWidget("RC2", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("FilesLabel", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- OFilesLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc2); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc1 = XtCreateManagedWidget("RC", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("GroupsLabel", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- OGroupsLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNverticalSpacing, 10); n++;
- XtSetArg (wargs[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNbottomWidget, bottom_form); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNorientation, XmVERTICAL); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNleftWidget, form); n++;
- sep = XtCreateManagedWidget("Sep", xmSeparatorGadgetClass,
- topform, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNleftWidget, sep); n++;
- XtSetArg (wargs[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNbottomWidget, bottom_form); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_FORM); n++;
- form = XtCreateManagedWidget( "DupIForm2", xmFormWidgetClass,
- topform, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- label = XtCreateManagedWidget("DuplicateLabel", xmLabelWidgetClass,
- form, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, label); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc1 = XtCreateManagedWidget("RC", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("NameLabel", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- DNameLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc1); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc2 = XtCreateManagedWidget("RC", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("CommandLabel", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- DCommandLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc2); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc3 = XtCreateManagedWidget("RC3", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("AltCommandLabel", xmLabelWidgetClass,
- rc3, wargs, n);
-
- n = 0;
- DAltCommandLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc3, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc3); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc2 = XtCreateManagedWidget("RC2", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("HelpFileLabel", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- DHelpFileLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc2); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc1 = XtCreateManagedWidget("RC", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("KeywordsLabel", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- DKeywordLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc1); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc2 = XtCreateManagedWidget("RC2", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("FilesLabel", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- DFilesLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc2, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, rc2); n++;
- XtSetArg (wargs[n], XmNorientation, XmHORIZONTAL); n++;
- rc1 = XtCreateManagedWidget("RC", xmRowColumnWidgetClass,
- form, wargs, n);
-
- n = 0;
- label = XtCreateManagedWidget("GroupsLabel", xmLabelWidgetClass,
- rc1, wargs, n);
-
- n = 0;
- DGroupsLabel = XtCreateManagedWidget("Label", xmLabelWidgetClass,
- rc1, wargs, n);
-
- return(DupIcons_shell);
- }
-
- void setup_dupicons()
- {
- struct icntmpltstruct *dup_ptr, *orig_ptr;
- XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
- char *bigstring;
- int len, biglen, maxlen;
- struct wordlist *tmpkey;
- struct grpliststruct *tmpgrps;
- struct filelist *tmpfiles;
- int i;
-
- maxlen = 32;
- bigstring = (char *)malloc( maxlen * sizeof(char) );
- biglen = 0;
- bigstring[0] = '\0';
- dup_ptr = duplicate_icons[dup_number];
- orig_ptr = dup_ptr->nameptr->icon;
-
- XtVaSetValues( ONameLabel, XmNlabelString,
- XmStringCreateLtoR(orig_ptr->nameptr->string, charset), NULL);
- if (orig_ptr->startstring != NULL)
- {
- len = strlen(orig_ptr->startstring);
- if (len > 50)
- {
- if (maxlen < len)
- {
- bigstring = (char *)realloc
- ( (void *)bigstring, (len + 5) * sizeof(char));
- maxlen = len + 5;
- }
- strcpy(bigstring, orig_ptr->startstring);
- i = find_blank(&(bigstring[30]));
- bigstring[i+30] = '\n';
- XtVaSetValues( OCommandLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- else
- XtVaSetValues( OCommandLabel, XmNlabelString,
- XmStringCreateLtoR(orig_ptr->startstring, charset), NULL);
- }
- else /* orig icon has no start string */
- {
- sprintf(bigstring, "(none)");
- XtVaSetValues( OCommandLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- if (orig_ptr->alt_command == NULL)
- {
- sprintf(bigstring, "(none)");
- XtVaSetValues( OAltCommandLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- else
- {
- len = strlen(orig_ptr->alt_command);
- if (len > 50) /* do I need to add a break in the alt command */
- {
- if (len > maxlen)
- {
- bigstring = (char *)realloc
- ( (void *)bigstring, (len + 5) * sizeof(char));
- maxlen = len + 5;
- }
- strcpy(bigstring, orig_ptr->alt_command);
- i = find_blank(&(bigstring[30]));
- bigstring[i+30] = '\n';
- XtVaSetValues( OAltCommandLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- else
- XtVaSetValues( OAltCommandLabel, XmNlabelString,
- XmStringCreateLtoR(orig_ptr->alt_command, charset), NULL);
- }
- if (orig_ptr->helpfile == NULL)
- {
- sprintf(bigstring, "(none)");
- XtVaSetValues( OHelpFileLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- else
- {
- XtVaSetValues( OHelpFileLabel, XmNlabelString,
- XmStringCreateLtoR(orig_ptr->helpfile->name, charset), NULL);
- }
-
- tmpkey = orig_ptr->keywords;
- tmpgrps = orig_ptr->grps;
- tmpfiles = orig_ptr->addtlfiles;
- biglen = 0;
- bigstring[0] = '\0';
- if (tmpkey == NULL) /* there are no keywords */
- {
- sprintf(bigstring, "(none)");
- }
- while (tmpkey != NULL)
- {
- if (biglen != 0)
- strcat(bigstring, ", ");
- biglen+=2;
- len = strlen(tmpkey->indexptr->string);
- if (len + 2 + biglen > maxlen)
- {
- maxlen += 32;
- bigstring = (char *) realloc ( (void *) bigstring, maxlen);
- }
- strcat(bigstring, tmpkey->indexptr->string);
- biglen = biglen + len;
- tmpkey = tmpkey->next;
- }
- XtVaSetValues( OKeywordLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- biglen = 0;
- bigstring[0] = '\0';
- if (tmpfiles == NULL) /* there are no files */
- {
- sprintf(bigstring, "(none)");
- }
- while (tmpfiles != NULL)
- {
- if (biglen != 0)
- strcat(bigstring, "\n");
- biglen+=2;
- len = strlen(tmpfiles->file->name);
- if (len + 2 + biglen > maxlen)
- {
- maxlen += 32;
- bigstring = (char *) realloc ( (void *) bigstring, maxlen);
- }
- strcat(bigstring, tmpfiles->file->name);
- biglen = biglen + len;
- tmpfiles = tmpfiles->next;
- }
- XtVaSetValues( OFilesLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- biglen = 0;
- bigstring[0] = '\0';
- if (tmpgrps == NULL) /* there are no groups */
- {
- sprintf(bigstring, "(none)");
- }
- while (tmpgrps != NULL)
- {
- if (biglen != 0)
- strcat(bigstring, ", ");
- biglen+=2;
- len = strlen(tmpgrps->grpptr->nameptr->string);
- if (len + 2 + biglen > maxlen)
- {
- maxlen += 32;
- bigstring = (char *) realloc ( (void *) bigstring, maxlen);
- }
- strcat(bigstring, tmpgrps->grpptr->nameptr->string);
- biglen = biglen + len;
- tmpgrps = tmpgrps->next;
- }
- XtVaSetValues( OGroupsLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
-
- XtVaSetValues( DNameLabel, XmNlabelString,
- XmStringCreateLtoR(dup_ptr->nameptr->string, charset), NULL);
- if (dup_ptr->startstring != NULL)
- {
- len = strlen(dup_ptr->startstring);
- if (len > 50)
- {
- if (maxlen < len)
- {
- bigstring = (char *)realloc( (void *)bigstring, (len + 5) * sizeof(char));
- maxlen = len + 5;
- }
- strcpy(bigstring, dup_ptr->startstring);
- i = find_blank(&(bigstring[30]));
- bigstring[i+30] = '\n';
- XtVaSetValues( DCommandLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- else
- XtVaSetValues( DCommandLabel, XmNlabelString,
- XmStringCreateLtoR(dup_ptr->startstring, charset), NULL);
- }
- else /* dup icon has no start string */
- {
- sprintf(bigstring, "(none)");
- XtVaSetValues( DCommandLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- if (dup_ptr->alt_command == NULL)
- {
- sprintf(bigstring, "(none)");
- XtVaSetValues( DAltCommandLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- else
- {
- len = strlen(dup_ptr->alt_command);
- if (len > 50) /* do I need to add a break in the alt command */
- {
- if (len > maxlen)
- {
- bigstring = (char *)realloc
- ( (void *)bigstring, (len + 5) * sizeof(char));
- maxlen = len + 5;
- }
- strcpy(bigstring, dup_ptr->alt_command);
- i = find_blank(&(bigstring[30]));
- bigstring[i+30] = '\n';
- XtVaSetValues( DAltCommandLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- else
- XtVaSetValues( DAltCommandLabel, XmNlabelString,
- XmStringCreateLtoR(dup_ptr->alt_command, charset), NULL);
- }
- if (dup_ptr->helpfile == NULL)
- {
- sprintf(bigstring, "(none)");
- XtVaSetValues( DHelpFileLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- }
- else
- {
- XtVaSetValues( DHelpFileLabel, XmNlabelString,
- XmStringCreateLtoR(dup_ptr->helpfile->name, charset), NULL);
- }
-
- tmpkey = dup_ptr->keywords;
- tmpgrps = dup_ptr->grps;
- tmpfiles = dup_ptr->addtlfiles;
- biglen = 0;
- bigstring[0] = '\0';
- while (tmpkey != NULL)
- {
- if (biglen != 0)
- strcat(bigstring, ", ");
- biglen+=2;
- len = strlen(tmpkey->indexptr->string);
- if (len + 2 + biglen > maxlen)
- {
- maxlen += 32;
- bigstring = (char *) realloc ( (void *) bigstring, maxlen);
- }
- strcat(bigstring, tmpkey->indexptr->string);
- biglen = biglen + len;
- tmpkey = tmpkey->next;
- }
- XtVaSetValues( DKeywordLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- biglen = 0;
- bigstring[0] = '\0';
- while (tmpfiles != NULL)
- {
- if (biglen != 0)
- strcat(bigstring, "\n");
- biglen+=2;
- len = strlen(tmpfiles->file->name);
- if (len + 2 + biglen > maxlen)
- {
- maxlen += 32;
- bigstring = (char *) realloc ( (void *) bigstring, maxlen);
- }
- strcat(bigstring, tmpfiles->file->name);
- biglen = biglen + len;
- tmpfiles = tmpfiles->next;
- }
- XtVaSetValues( DFilesLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- biglen = 0;
- bigstring[0] = '\0';
- while (tmpgrps != NULL)
- {
- if (biglen != 0)
- strcat(bigstring, ", ");
- biglen+=2;
- len = strlen(tmpgrps->grpptr->nameptr->string);
- if (len + 2 + biglen > maxlen)
- {
- maxlen += 32;
- bigstring = (char *) realloc ( (void *) bigstring, maxlen);
- }
- strcat(bigstring, tmpgrps->grpptr->nameptr->string);
- biglen = biglen + len;
- tmpgrps = tmpgrps->next;
- }
- XtVaSetValues( DGroupsLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
-
- }
-
- Widget popup_DupIcons()
- {
- dup_number = 0;
- setup_dupicons();
-
- XtPopup(DupIcons_w, XtGrabNone);
- }
-
- Widget create_AskDupIcons()
- {
- Widget topform;
- Widget r_button, i_button;
- Arg wargs[15];
- int n;
-
- AskDupIcons_shell = XtVaCreatePopupShell( "AskDupIconsshell",
- topLevelShellWidgetClass, DBtoplevel,
- XmNallowShellResize, TRUE, NULL);
-
- n = 0;
- XtSetArg (wargs[n], XmNverticalSpacing, 10); n++;
- XtSetArg (wargs[n], XmNhorizontalSpacing, 10); n++;
- topform = XtCreateManagedWidget("AskDupIconsTopForm", xmFormWidgetClass,
- AskDupIcons_shell, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNtopOffset, 15); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg (wargs[n], XmNborderWidth, 0); n++;
- AskDupLabel = XtCreateManagedWidget("LegendLabel", xmLabelWidgetClass,
- topform, wargs, n);
-
- n = 0;
- XtSetArg (wargs[n], XmNtopOffset, 10); n++;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, AskDupLabel); n++;
- XtSetArg (wargs[n], XmNbottomAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_FORM); n++;
- r_button = XtCreateManagedWidget( "ResolveButton", xmPushButtonWidgetClass,
- topform, wargs, n);
- XtAddCallback( r_button, XmNactivateCallback, resolveCB_AskDupIcons, NULL);
-
- n = 0;
- XtSetArg (wargs[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNtopWidget, AskDupLabel); n++;
- XtSetArg (wargs[n], XmNtopOffset, 10); n++;
- XtSetArg (wargs[n], XmNbottomAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (wargs[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (wargs[n], XmNleftWidget, r_button); n++;
- i_button = XtCreateManagedWidget( "IgnoreButton", xmPushButtonWidgetClass,
- topform, wargs, n);
- XtAddCallback( i_button, XmNactivateCallback, ignoreCB_AskDupIcons, NULL);
-
- XtRealizeWidget(AskDupIcons_shell);
- SetWMhints(AskDupIcons_shell);
- return(AskDupIcons_shell);
- }
-
- void ask_user_duplicate_icons(int dup_icn_cnt)
- {
- if (dup_icn_cnt > 0)
- {
- popup_AskDupIcons(dup_icn_cnt);
- }
- }
-
- void popup_AskDupIcons(int dup_icn_cnt)
- {
- char *bigstring;
- XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
-
-
- bigstring = malloc( 38 * 5 * sizeof (char) );
- if (dup_icn_cnt == 1)
- {
- strcat(bigstring, "One demo in the appended file\n");
- strcat(bigstring, "has the same name as a demo\n");
- strcat(bigstring, "already in the database. Do\n");
- strcat(bigstring, "you want to resolve the conflict,\n");
- strcat(bigstring, "or leave them as possible duplicates?");
- }
- else
- {
- sprintf(bigstring, "Some demos (%d) in the appended\n", dup_icn_cnt);
- strcat(bigstring, "file have the same name as demos\n");
- strcat(bigstring, "already in the database. Do\n");
- strcat(bigstring, "you want to resolve the conflicts,\n");
- strcat(bigstring, "or leave them as possible duplicates?\n");
- }
- XtVaSetValues( AskDupLabel, XmNlabelString,
- XmStringCreateLtoR(bigstring, charset), NULL);
- XtPopup(AskDupIcons_w, XtGrabNone);
- }
-
- void noCB_DupIcons(Widget w, XtPointer client_data, XtPointer call_data)
- {
- char *newname;
- int len;
- int i;
- struct indexlist *tmpname;
-
- len = strlen(duplicate_icons[dup_number]->nameptr->string);
- newname = malloc(len + 5);
- sprintf(newname, "%s 1", duplicate_icons[dup_number]->nameptr->string);
- i = 2;
- while ((tmpname = find_keyword(newname) )!= NULL )
- {
- sprintf(newname, "%s %d", duplicate_icons[dup_number]->nameptr->string, i);
- i++;
- }
- duplicate_icons[dup_number]->nameptr = add_keyword(newname);
- duplicate_icons[dup_number]->nameptr->icon = duplicate_icons[dup_number];
- if (dup_number == dup_icn_cnt-1)
- XtPopdown(DupIcons_w);
- else
- {
- dup_number++;
- setup_dupicons();
- }
- }
-
- void handle_dup(int number)
- {
- struct icntmpltstruct *dup_ptr, *orig_ptr, *prev_ptr;
- struct wordlist *dupkey, *tk;
- struct grpliststruct *dupgrps, *tg;
- struct filelist *dupfiles, *tf, *origfiles;
- struct indexlist *indexptr;
- struct iconstruct *origiconptr, *dupiconptr, *previconptr;
- struct grptmpltstruct *grpptr;
- struct wordlist *klist;
- struct grpliststruct *glist;
- Boolean found_orig;
-
- dup_ptr = duplicate_icons[dup_number];
- orig_ptr = dup_ptr->nameptr->icon;
-
- dupkey = dup_ptr->keywords;
- dupgrps = dup_ptr->grps;
- dupfiles = dup_ptr->addtlfiles;
- /* FILES */
- while (dupfiles != NULL)
- {
- while (dupfiles != NULL)
- {
- /* check for each dup file in the orig file list */
- tf = dupfiles->next;
- origfiles = orig_ptr->addtlfiles;
- while (origfiles != NULL && origfiles->file != dupfiles->file)
- origfiles = origfiles->next;
- if (origfiles == NULL)
- {
- /* if not found, add the dupfile struct to the orig files list */
- dupfiles->next = orig_ptr->addtlfiles;
- orig_ptr->addtlfiles = dupfiles;
- }
- else
- {
- /* if found, toss the dupfiles structure */
- free(dupfiles);
- }
- dupfiles = tf;
- }
- }
- /* GROUPS */
- while (dupgrps != NULL)
- {
- previconptr = NULL;
- found_orig = FALSE;
- grpptr = dupgrps->grpptr;
- dupiconptr = grpptr->firstpage->fronticons;
- while (dupiconptr != NULL && dupiconptr->iconptr != dup_ptr)
- {
- if (dupiconptr->iconptr == orig_ptr)
- {
- origiconptr = dupiconptr;
- found_orig = TRUE;
- }
- previconptr = dupiconptr;
- dupiconptr = dupiconptr->nexticon;
- }
- if (!found_orig) /* didn't file ref to orig demo so far in icon list */
- {
- origiconptr = dupiconptr;
- while (origiconptr != NULL && !found_orig)
- {
- if (origiconptr->iconptr == orig_ptr)
- found_orig = TRUE;
- else
- origiconptr = origiconptr->nexticon;
- }
- }
- if (found_orig) /* delete the reference to dup demo */
- {
- if (previconptr == NULL)
- grpptr->firstpage->fronticons = dupiconptr->nexticon;
- else
- previconptr->nexticon = dupiconptr->nexticon;
- free(dupiconptr);
- group_setup(NULL, NULL, grpptr);
- }
- else /* replace ref to dup demo with ref to orig demo */
- {
- dupiconptr->iconptr = orig_ptr;
- orig_ptr->occurences++;
- glist = orig_ptr->grps;
- orig_ptr->grps = (struct grpliststruct *) malloc
- (sizeof(struct grpliststruct) );
- orig_ptr->grps->grpptr = grpptr;
- orig_ptr->grps->next = glist;
- orig_ptr->grps->prev = glist;
- if (glist != NULL)
- glist->prev = orig_ptr->grps;
- }
- dupgrps = dupgrps->next;
- }
-
- /* KEYWORDS */
- while (dupkey != NULL)
- {
- found_orig = FALSE;
- previconptr = NULL;
- indexptr = dupkey->indexptr;
- dupiconptr = indexptr->icons;
- while (dupiconptr->iconptr != dup_ptr && dupiconptr->iconptr != dup_ptr)
- {
- if (dupiconptr->iconptr == orig_ptr)
- {
- origiconptr = dupiconptr;
- found_orig = TRUE;
- }
- previconptr = dupiconptr;
- dupiconptr = dupiconptr->nexticon;
- }
- /* does the original demo also use this keyword? */
- if (!found_orig) /* didn't file ref to orig demo so far in icon list */
- {
- origiconptr = dupiconptr;
- while (origiconptr != NULL && !found_orig)
- {
- if (origiconptr->iconptr == orig_ptr)
- found_orig = TRUE;
- else
- origiconptr = origiconptr->nexticon;
- }
- }
- if (found_orig) /* delete the reference to dup demo */
- {
- indexptr->count--;
- if (previconptr == NULL)
- indexptr->icons = dupiconptr->nexticon;
- else
- previconptr->nexticon = dupiconptr->nexticon;
- free(dupiconptr);
- }
- else /* replace ref to dup demo with ref to orig demo */
- {
- dupiconptr->iconptr = orig_ptr;
- /* add the new keyword to the orig icons list of keywords */
- klist = orig_ptr->keywords;
- orig_ptr->keywords = (struct wordlist *)
- malloc (sizeof (struct wordlist) );
- orig_ptr->keywords->next = klist;
- orig_ptr->keywords->indexptr = indexptr;
- }
- dupkey = dupkey->next;
- }
- /* clean up storage */
- if (dup_ptr == firsticon)
- firsticon = dup_ptr->nexticntmplt;
- else
- {
- prev_ptr = firsticon;
- while (prev_ptr != NULL && prev_ptr->nexticntmplt != dup_ptr)
- {
- prev_ptr = prev_ptr->nexticntmplt;
- }
- if (prev_ptr != NULL)
- {
- prev_ptr->nexticntmplt = dup_ptr->nexticntmplt;
- if (dup_ptr == lasticon)
- lasticon = prev_ptr;
- }
- }
- free(dup_ptr->poly);
- dupkey = dup_ptr->keywords;
- while (dupkey != NULL)
- {
- tk = dupkey->next;
- free(dupkey);
- dupkey = tk;
- }
- dup_ptr->nameptr->count--;
- free(dup_ptr->startstring);
- dupgrps = dup_ptr->grps;
- while (dupgrps != NULL)
- {
- tg = dupgrps->next;
- free(dupgrps);
- dupgrps = tg;
- }
- dupfiles = dup_ptr->addtlfiles;
- free(dup_ptr);
- }
-
-
- void yesCB_DupIcons(Widget w, XtPointer client_data, XtPointer call_data)
- {
- handle_dup(dup_number);
- if (dup_number == dup_icn_cnt-1)
- XtPopdown(DupIcons_w);
- else
- {
- dup_number++;
- setup_dupicons();
- }
- }
-
- void resolveCB_AskDupIcons(Widget w, XtPointer client_data, XtPointer call_data)
- {
- XtPopdown(AskDupIcons_w);
-
- popup_DupIcons();
- }
-
- void ignoreCB_AskDupIcons(Widget w, XtPointer client_data, XtPointer call_data)
- {
- XtPopdown(AskDupIcons_w);
- }
-
-